package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JBDCDemo5{
    public static void main(String[] args) throws Exception{
        Connection  conn = DBUtil.getConnection();
        Statement  state  = conn.createStatement();
        String sql = "SELECT id,name,salary,title FROM teacher";
        ResultSet rs = state.executeQuery(sql);
        while(rs.next()){
            int id = rs.getInt("id");
            String name = rs.getString("name");
            double salary = rs.getDouble("salary");
            String title = rs.getString("title");
            System.out.println(id+"--"+name+"--"+salary+"--"+title);
        }
        conn.close();
    }

}
